package com.me.mygdxgame.models;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.me.mygdxgame.assets.Assets;

public class PotGold extends AbstractGameObject{

	private Texture texPotGold;
	private TextureRegion regPotGold;
	public boolean collected;
	private TextureRegion[] potFrames;
	private TextureRegion[] temp;
	private float stateTime = 0;
	private Animation potAnimation;
	
	public PotGold(){
		init();
	}
	
	private void init() {
//		texPotGold = Assets.potgold;
//		regPotGold = new TextureRegion(texPotGold, 0, 0, 40, 40);
//		sprite.setRegion(regPotGold);
		temp = TextureRegion.split(Assets.potgold, 40, 40)[0];
		potFrames = getTextures(1, 8, temp);
		potAnimation = new Animation(0.2f, potFrames);
//		dimension.set(40, 40);
		sprite.setSize(40, 40);
//		bounds.set(0, 0, dimension.x, dimension.y);
		collected = false;
	}

	
	@Override
	public void update(float deltaTime) {
		super.update(deltaTime);
		stateTime += deltaTime;
	}

	@Override
	public void render(SpriteBatch batch) {
		if(collected)return;
//		TextureRegion reg = null;
//		reg = regPotGold;
//		batch.draw(reg.getTexture(),
//				position.x, position.y,
//				origin.x, origin.y,
//				dimension.x, dimension.y,
//				scale.x, scale.y,
//				rotation,
//				reg.getRegionX(), reg.getRegionY(),
//				reg.getRegionWidth(), reg.getRegionHeight(), 
//				false, false
//				);
		sprite.setRegion(potAnimation.getKeyFrame(stateTime, true));
		sprite.draw(batch);
	}

}
